package com.example.work2

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Message
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        replaceFragment(MessageFragment())
        message_image.setOnClickListener{
            replaceFragment(MessageFragment())
        }
        txl_image.setOnClickListener{
            replaceFragment(TxlFragment())
        }
        fx_image.setOnClickListener{
            replaceFragment(FxFragment())
        }
        me_image.setOnClickListener {
            replaceFragment(MeFragment())
        }
    }
    private fun replaceFragment(fragment: Fragment){
        val fragmentManager=supportFragmentManager
        val transaction=fragmentManager.beginTransaction()
        transaction.replace(R.id.content,fragment)
        transaction.commit()
    }
}